<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:Controls="clr-namespace:MahApps.Metro.Controls"
                    xmlns:Behaviours="clr-namespace:MahApps.Metro.Behaviours"
                    xmlns:conv="clr-namespace:MahApps.Metro.Converters"
                    xmlns:sys="clr-namespace:System;assembly=mscorlib">
    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colours.xaml" />
        <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
    </ResourceDictionary.MergedDictionaries>

    <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>

    <Style TargetType="{x:Type Controls:PanoramaItem}">
        <Setter Property="HorizontalContentAlignment"
                Value="Stretch" />
        <Setter Property="VerticalContentAlignment"
                Value="Stretch" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Controls:PanoramaItem}">
                    <Grid Background="{TemplateBinding Background}"
                          Margin="12,0,0,0">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="*" />
                        </Grid.RowDefinitions>
                        <ContentControl x:Name="header"
                                        Opacity="{TemplateBinding HeaderOpacity}"
                                        ContentTemplate="{TemplateBinding HeaderTemplate}"
                                        Content="{TemplateBinding Header}"
                                        FontSize="70"
                                        HorizontalAlignment="Left"
                                        Margin="10,-2,0,26">
                        </ContentControl>
                        <ContentPresenter RecognizesAccessKey="True"
                                          Content="{TemplateBinding Content}"
                                          HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                          Margin="{TemplateBinding Padding}"
                                          Grid.Row="1"
                                          VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type Controls:Panorama}">
        <Setter Property="ItemsPanel">
            <Setter.Value>
                <ItemsPanelTemplate>
                    <StackPanel Orientation="Horizontal" />
                </ItemsPanelTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Controls:Panorama}">
                    <ItemsPresenter />
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>


    <Style TargetType="{x:Type Controls:ToggleSwitchButton}">
        <Setter Property="IsTabStop" Value="False" />
        <Setter Property="SwitchForeground" Value="{DynamicResource AccentColorBrush}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Controls:ToggleSwitchButton}">
                    <Border x:Name="Root"
        						BorderBrush="{TemplateBinding BorderBrush}"
        						BorderThickness="{TemplateBinding BorderThickness}"
        						Opacity="{TemplateBinding Opacity}"
        						Padding="{TemplateBinding Padding}">
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualState x:Name="Normal" />
                                <VisualState x:Name="Disabled" />
                                <VisualState x:Name="MouseOver">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="hover">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Visible}"/>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Pressed">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="pressed">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Visible}"/>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="CheckStates">
                                <VisualStateGroup.Transitions>
                                    <VisualTransition GeneratedDuration="0:0:0.05" To="Unchecked" />
                                    <VisualTransition GeneratedDuration="0:0:0.05" To="Checked" >
                                        <Storyboard>
                                            <DoubleAnimation Duration="0:0:0.05" To="47" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)" Storyboard.TargetName="SwitchThumb">
                                                <DoubleAnimation.EasingFunction>
                                                    <CircleEase EasingMode="EaseIn"/>
                                                </DoubleAnimation.EasingFunction>
                                            </DoubleAnimation>
                                        </Storyboard>
                                    </VisualTransition>
                                </VisualStateGroup.Transitions>
                                <VisualState x:Name="Checked">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="BackgroundTranslation"
        											Storyboard.TargetProperty="(TranslateTransform.X)"
        											Duration="0"
        											To="68">
                                            <DoubleAnimation.EasingFunction>
                                                <ExponentialEase Exponent="15" EasingMode="EaseOut" />
                                            </DoubleAnimation.EasingFunction>
                                        </DoubleAnimation>
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)" Storyboard.TargetName="SwitchThumb">
                                            <EasingDoubleKeyFrame KeyTime="0" Value="47"/>
                                        </DoubleAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Dragging" />
                                <VisualState x:Name="Unchecked">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="BackgroundTranslation"
        											Storyboard.TargetProperty="(TranslateTransform.X)"
        											Duration="0"
        											To="0" />
                                        <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)" Storyboard.TargetName="border">
                                            <EasingColorKeyFrame KeyTime="0" Value="#CC9B9B9B"/>
                                        </ColorAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <Grid x:Name="SwitchRoot" Background="{x:Null}" Height="Auto" Width="Auto" UseLayoutRounding="True">
                            <Grid x:Name="SwitchTrack" Width="Auto">
                                <Grid x:Name="SwitchBottom" Height="25" Width="60">
                                    <Rectangle x:Name="SwitchBackground"
        										Width="Auto"
        										Height="Auto"
        										HorizontalAlignment="Stretch"
        										VerticalAlignment="Stretch">
                                        <Rectangle.RenderTransform>
                                            <TranslateTransform x:Name="BackgroundTranslation" />
                                        </Rectangle.RenderTransform>
                                    </Rectangle>
                                    <Border BorderThickness="2" BorderBrush="{DynamicResource GrayBrush9}">
                                        <Grid Margin="2">
                                            <Border x:Name="border" BorderThickness="0" Background="{DynamicResource AccentColorBrush}" Margin="0" />
                                            <Border x:Name="pressed" BorderThickness="0" Background="{DynamicResource {x:Static SystemColors.WindowBrushKey}}" Opacity="0.25" Visibility="Collapsed" Margin="0" />
                                            <Border x:Name="hover" BorderThickness="0" Background="{DynamicResource {x:Static SystemColors.WindowBrushKey}}" Opacity="0.15" Visibility="Collapsed" Margin="0" />
                                        </Grid>
                                    </Border>
                                </Grid>
                                <Border x:Name="SwitchThumb"
        									BorderBrush="{TemplateBinding Background}"
        									BorderThickness="0"
        									Margin="0"
        									Width="13"
        									Height="Auto"
        									HorizontalAlignment="Left">
                                    <Border.RenderTransform>
                                        <TransformGroup>
                                            <ScaleTransform/>
                                            <SkewTransform/>
                                            <RotateTransform/>
                                            <TranslateTransform/>
                                        </TransformGroup>
                                    </Border.RenderTransform>
                                    <Border x:Name="ThumbCenter" BorderBrush="{TemplateBinding Foreground}" BorderThickness="0" Background="{DynamicResource BlackBrush}" />
                                </Border>
                            </Grid>
                        </Grid>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type Controls:ToggleSwitch}">
        <Setter Property="IsTabStop" Value="False" />
        <Setter Property="SwitchForeground" Value="{DynamicResource AccentColorBrush}" />
        <Setter Property="HorizontalContentAlignment" Value="Left" />
        <Setter Property="VerticalContentAlignment" Value="Top" />
        <Setter Property="Foreground" Value="{DynamicResource BlackBrush}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Controls:ToggleSwitch}">
                    <Border BorderBrush="{TemplateBinding BorderBrush}"
        						BorderThickness="{TemplateBinding BorderThickness}"
        						Padding="{TemplateBinding Padding}">
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualState x:Name="Normal" />
                                <VisualState x:Name="Disabled">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="Header" Storyboard.TargetProperty="(UIElement.Opacity)" Duration="0" To="0.3" />
                                        <DoubleAnimation Storyboard.TargetName="Content" Storyboard.TargetProperty="(UIElement.Opacity)" Duration="0" To="0.3" />
                                        <DoubleAnimation Storyboard.TargetName="Switch" Storyboard.TargetProperty="(UIElement.Opacity)" Duration="0"  To="0.75" />
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <Grid Margin="12,5,0,0">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="Auto" />
                            </Grid.RowDefinitions>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*" />
                                <ColumnDefinition Width="Auto" />
                            </Grid.ColumnDefinitions>
                            <ContentControl x:Name="Header"
        								FontWeight="Normal"
        								Content="{TemplateBinding Header}"
        								ContentTemplate="{TemplateBinding HeaderTemplate}"
        								HorizontalAlignment="Left"
        								IsTabStop="False"
        								Margin="0,0,0,5"
        								Opacity="0.65"
        								VerticalAlignment="Top" Grid.ColumnSpan="3" FontSize="16" BorderThickness="0" />
                            <ContentControl x:Name="Content"
        								Grid.Row="1"
        								Content="{TemplateBinding Content}"
        								ContentTemplate="{TemplateBinding ContentTemplate}"
        								HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
        								IsTabStop="False"
        								Margin="-1,1,0,-7"
        								VerticalAlignment="{TemplateBinding VerticalContentAlignment}" FontFamily="Segoe UI Semibold" FontSize="14.667" />
                            <Controls:ToggleSwitchButton x:Name="Switch"
        								Grid.RowSpan="1"
        								Grid.Column="1"
        								Background="{TemplateBinding Background}"
        								SwitchForeground="{TemplateBinding SwitchForeground}"
        								VerticalAlignment="Bottom" HorizontalAlignment="Right" Grid.Row="1" />
                        </Grid>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type Controls:MetroContentControl}">
        <Setter Property="Foreground"
                Value="#FF000000" />
        <Setter Property="HorizontalContentAlignment"
                Value="Stretch" />
        <Setter Property="VerticalContentAlignment"
                Value="Stretch" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Controls:MetroContentControl">
                    <Grid x:Name="root"
                          RenderTransformOrigin="0.5,0.5">
                        <Grid.RenderTransform>
                            <TranslateTransform />
                        </Grid.RenderTransform>
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="LayoutStates">
                                <VisualState x:Name="AfterLoaded">
                                    <Storyboard>
                                        <DoubleAnimationUsingKeyFrames BeginTime="00:00:00"
                                                                       Storyboard.TargetProperty="(UIElement.Opacity)"
                                                                       Storyboard.TargetName="root">
                                            <SplineDoubleKeyFrame KeyTime="00:00:00"
                                                                  Value="0" />
                                            <SplineDoubleKeyFrame KeyTime="00:00:00.400"
                                                                  Value="1" />
                                        </DoubleAnimationUsingKeyFrames>
                                        <DoubleAnimationUsingKeyFrames BeginTime="00:00:00"
                                                                       Storyboard.TargetProperty="(UIElement.RenderTransform).(TranslateTransform.X)"
                                                                       Storyboard.TargetName="root">
                                            <SplineDoubleKeyFrame KeyTime="00:00:00"
                                                                  Value="-30" />
                                            <EasingDoubleKeyFrame KeyTime="00:00:00.700"
                                                                  Value="0">
                                                <EasingDoubleKeyFrame.EasingFunction>
                                                    <CubicEase EasingMode="EaseOut" />
                                                </EasingDoubleKeyFrame.EasingFunction>
                                            </EasingDoubleKeyFrame>
                                        </DoubleAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="AfterUnLoaded">
                                    <Storyboard>
                                        <DoubleAnimationUsingKeyFrames BeginTime="00:00:00"
                                                                       Storyboard.TargetProperty="(UIElement.Opacity)"
                                                                       Storyboard.TargetName="root">
                                            <SplineDoubleKeyFrame KeyTime="00:00:00"
                                                                  Value="1" />
                                            <SplineDoubleKeyFrame KeyTime="00:00:00.100"
                                                                  Value="0" />
                                        </DoubleAnimationUsingKeyFrames>
                                        <DoubleAnimationUsingKeyFrames BeginTime="00:00:00"
                                                                       Storyboard.TargetProperty="(UIElement.RenderTransform).(TranslateTransform.X)"
                                                                       Storyboard.TargetName="root">
                                            <SplineDoubleKeyFrame KeyTime="00:00:00"
                                                                  Value="0" />
                                            <SplineDoubleKeyFrame KeyTime="00:00:00.100"
                                                                  Value="-30" />
                                        </DoubleAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="BeforeLoaded" />
                                <VisualState x:Name="BeforeUnloaded" />
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <ContentPresenter Cursor="{TemplateBinding Cursor}"
                                          ContentTemplate="{TemplateBinding ContentTemplate}"
                                          Content="{TemplateBinding Content}"
                                          HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                          Margin="{TemplateBinding Padding}"
                                          VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="Controls:Tile">
        <Setter Property="Width"
                Value="140" />
        <Setter Property="Height"
                Value="140" />
        <Setter Property="Margin"
                Value="3" />
        <Setter Property="Foreground"
                Value="White" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Controls:Tile">
                    <Grid>
                        <Grid.Background>
                            <SolidColorBrush Color="{DynamicResource AccentColor}" />
                        </Grid.Background>

                        <StackPanel VerticalAlignment="Center"
                                    HorizontalAlignment="Center"
                                    Orientation="Horizontal">
                            <ContentPresenter RecognizesAccessKey="True" />

                            <TextBlock Text="{TemplateBinding Count}"
                                       FontSize="28"
                                       VerticalAlignment="Center" />
                        </StackPanel>

                        <Label Grid.ColumnSpan="2"
                               HorizontalAlignment="Left"
                               VerticalAlignment="Bottom"
                               Foreground="{TemplateBinding Foreground}">
                            <AccessText Text="{Binding Title, RelativeSource={RelativeSource TemplatedParent}}"
                                        Foreground="{TemplateBinding Foreground}"
                                        TextWrapping="Wrap"
                                        FontSize="16"
                                        Margin="3" />
                        </Label>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="Button.IsPressed"
                                 Value="True">
                            <Setter Property="RenderTransform">
                                <Setter.Value>
                                    <ScaleTransform ScaleX="0.98"
                                                    ScaleY="0.98"
                                                    CenterX="0.5"
                                                    CenterY="0.5" />
                                </Setter.Value>
                            </Setter>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="Controls:MetroImage">
        <Setter Property="Width"
                Value="48" />
        <Setter Property="Height"
                Value="48" />
        <Setter Property="Foreground"
                Value="White" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Controls:MetroImage">
                    <Rectangle Width="{TemplateBinding Width}"
                               Height="{TemplateBinding Height}"
                               Fill="{TemplateBinding Foreground}">
                        <Rectangle.OpacityMask>
                            <VisualBrush Visual="{Binding Source, RelativeSource={RelativeSource TemplatedParent}}"
                                         Stretch="Fill" />
                        </Rectangle.OpacityMask>
                    </Rectangle>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="Controls:AppBarButton">
        <Setter Property="Background"
                Value="{DynamicResource ButtonNormalBackground}" />
        <Setter Property="BorderBrush"
                Value="{DynamicResource ButtonNormalBorder}" />
        <Setter Property="BorderThickness"
                Value="1" />
        <Setter Property="HorizontalContentAlignment"
                Value="Center" />
        <Setter Property="VerticalContentAlignment"
                Value="Center" />
        <Setter Property="Padding"
                Value="1" />
        <Setter Property="FontSize"
                Value="12" />
        <Setter Property="Width"
                Value="80" />
        <Setter Property="Height"
                Value="80" />
        <Setter Property="Foreground"
                Value="{DynamicResource BlackBrush}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Controls:AppBarButton}">
                    <Grid x:Name="grid"
                          Background="#02FFFFFF"
                          Margin="{TemplateBinding Padding}">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="*" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>
                        <Viewbox>
                            <Grid>
                                <Ellipse x:Name="ellipsebg"
                                         Stroke="{TemplateBinding Foreground}"
                                         StrokeThickness="0"
                                         VerticalAlignment="Stretch"
                                         Width="48"
                                         Height="48" />
                                <Ellipse x:Name="ellipse"
                                         Stroke="{TemplateBinding Foreground}"
                                         StrokeThickness="2"
                                         VerticalAlignment="Stretch"
                                         Width="48"
                                         Height="48" />
                                <Rectangle Width="28"
                                           Height="28"
                                           Fill="{TemplateBinding Foreground}">
                                    <Rectangle.OpacityMask>
                                        <VisualBrush Visual="{Binding MetroImageSource, RelativeSource={RelativeSource TemplatedParent}}"
                                                     Stretch="Fill" />
                                    </Rectangle.OpacityMask>
                                </Rectangle>
                            </Grid>
                        </Viewbox>
                        <ContentPresenter RecognizesAccessKey="True"
                                          HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                          SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                                          VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                          Grid.Row="1" />
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsPressed"
                                 Value="True">
                            <Setter TargetName="ellipsebg"
                                    Property="Fill"
                                    Value="{DynamicResource BlackBrush}" />
                            <Setter TargetName="ellipsebg"
                                    Property="Opacity"
                                    Value="0.2" />
                        </Trigger>
                        <Trigger Property="IsMouseOver"
                                 Value="True">
                            <Setter TargetName="ellipse"
                                    Property="Opacity"
                                    Value="1" />
                        </Trigger>
                        <Trigger Property="IsMouseOver"
                                 Value="False">
                            <Setter TargetName="ellipse"
                                    Property="Opacity"
                                    Value=".5" />
                        </Trigger>
                        <Trigger Property="IsKeyboardFocused"
                                 Value="true" />
                        <Trigger Property="ToggleButton.IsChecked"
                                 Value="true" />
                        <Trigger Property="IsEnabled"
                                 Value="false">
                            <Setter Property="Foreground"
                                    Value="#ADADAD" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>


    <ControlTemplate x:Key="WindowTemplateKey" TargetType="{x:Type Controls:MetroWindow}">
        <Border x:Name="PART_Border" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}">
            <Grid>
                <AdornerDecorator>
                    <Controls:MetroContentControl>
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="auto"/>
                                <RowDefinition Height="*"/>
                            </Grid.RowDefinitions>
                            <Grid x:Name="PART_TitleBar" Height="30" Visibility="{TemplateBinding ShowTitleBar, Converter={StaticResource BooleanToVisibilityConverter}}">
                                <Grid.Background>
                                    <SolidColorBrush Color="{DynamicResource AccentColor}"/>
                                </Grid.Background>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="auto"/>
                                    <ColumnDefinition Width="*"/>
                                </Grid.ColumnDefinitions>
                                <Image
                                    Visibility="{TemplateBinding ShowIconOnTitleBar, Converter={StaticResource BooleanToVisibilityConverter}}"
                                    Source="{TemplateBinding Icon}"/>
                                <TextBlock
                                    Grid.Column="1"
                                    Text="{TemplateBinding Title, Converter={conv:ToUpperConverter}}"
                                    HorizontalAlignment="Left" 
                                    TextTrimming="CharacterEllipsis"
                                    VerticalAlignment="Center" 
                                    Margin="8 0 0 0" 
                                    FontSize="16" 
                                    FontFamily="{DynamicResource HeaderFontFamily}"
                                    Foreground="White"/>
                            </Grid>
                            <ContentPresenter 
                                Content="{Binding WindowCommands, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Controls:MetroWindow}}}" 
                                x:Name="PART_WindowCommands"
                                Panel.ZIndex="1"
                                Grid.RowSpan="2"
                                VerticalAlignment="Top"
                                HorizontalAlignment="Right" />
                            <ContentPresenter Grid.Row="1"/>
                        </Grid>
                    </Controls:MetroContentControl>
                </AdornerDecorator>
                <ResizeGrip x:Name="WindowResizeGrip" HorizontalAlignment="Right" IsTabStop="false" Visibility="Collapsed" VerticalAlignment="Bottom"/>
            </Grid>
        </Border>
        <ControlTemplate.Triggers>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="ResizeMode" Value="CanResizeWithGrip"/>
                    <Condition Property="WindowState" Value="Normal"/>
                </MultiTrigger.Conditions>
                <Setter Property="Visibility" TargetName="WindowResizeGrip" Value="Visible"/>
            </MultiTrigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <Style TargetType="{x:Type Controls:MetroWindow}">
        <Setter Property="Foreground">
            <Setter.Value>
                <SolidColorBrush Color="{DynamicResource BlackColor}"/>
            </Setter.Value>
        </Setter>
        <Setter Property="Background">
            <Setter.Value>
                <SolidColorBrush Color="{DynamicResource WhiteColor}"/>
            </Setter.Value>
        </Setter>
        <Setter Property="Behaviours:StylizedBehaviors.Behaviors">
            <Setter.Value>
                <Behaviours:StylizedBehaviorCollection>
                    <Behaviours:BorderlessWindowBehavior/>
                </Behaviours:StylizedBehaviorCollection>
            </Setter.Value>
        </Setter>
        <Setter Property="Template" Value="{StaticResource WindowTemplateKey}"/>
    </Style>

    <Style TargetType="{x:Type Controls:WindowCommands}">
        <Setter Property="Foreground" Value="{DynamicResource BlackBrush}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Controls:WindowCommands">
                    <ControlTemplate.Resources>
                        <ResourceDictionary>
                            <ResourceDictionary.MergedDictionaries>
                                <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
                            </ResourceDictionary.MergedDictionaries>
                            <sys:String x:Key="WindowCommandsMinimiseToolTip">Minimise</sys:String>
                            <sys:String x:Key="WindowCommandsMaximiseToolTip">Maximise</sys:String>
                            <sys:String x:Key="WindowCommandsRestoreToolTip">Restore</sys:String>
                            <sys:String x:Key="WindowCommandsCloseToolTip">Close</sys:String>
                        </ResourceDictionary>
                    </ControlTemplate.Resources>
                    <StackPanel Height="20" Margin="0,5,5,0" Orientation="Horizontal">
                        <ItemsControl ItemsSource="{Binding Items, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Controls:WindowCommands}}}">
                            <ItemsControl.ItemsPanel>
                                <ItemsPanelTemplate>
                                    <StackPanel Orientation="Horizontal" />
                                </ItemsPanelTemplate>
                            </ItemsControl.ItemsPanel>

                            <ItemsControl.ItemContainerStyle>
                                <Style TargetType="{x:Type Button}">
                                    <Setter Property="Background" Value="#02FFFFFF" />
                                    <Setter Property="HorizontalContentAlignment" Value="Center" />
                                    <Setter Property="VerticalContentAlignment" Value="Center" />
                                    <Setter Property="Padding" Value="1" />
                                    <Setter Property="Template">
                                        <Setter.Value>
                                            <ControlTemplate TargetType="{x:Type Button}">
                                                    <Grid Background="{TemplateBinding Background}">
                                                    <ContentPresenter x:Name="contentPresenter"
                                                            HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                                            VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                                            SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                                                            RecognizesAccessKey="True"
                                                            Opacity="0.75" Margin="11,1,11,1" />
                                                    
                                                    <Rectangle x:Name="border" 
                                                               SnapsToDevicePixels="True"
                                                               IsHitTestVisible="False" 
                                                               Opacity="0.25"
                                                               Width="0" Height="15" VerticalAlignment="Stretch" HorizontalAlignment="Right" 
                                                               Fill="{TemplateBinding Foreground}" Margin="10,0,0,0" />
                                                </Grid>
                                                <ControlTemplate.Triggers>
                                                    <Trigger Property="IsMouseOver" Value="True">
                                                        <Setter TargetName="contentPresenter" Property="Opacity" Value="1" />
                                                    </Trigger>
                                                    <Trigger Property="IsMouseOver" Value="False">
                                                        <Setter TargetName="contentPresenter" Property="Opacity" Value=".5" />
                                                    </Trigger>
                                                    <Trigger Property="IsKeyboardFocused" Value="true" />
                                                    <Trigger Property="ToggleButton.IsChecked" Value="true" />
                                                    <Trigger Property="IsEnabled" Value="false">
                                                        <Setter Property="Foreground" Value="#ADADAD" />
                                                    </Trigger>
                                                    <DataTrigger Binding="{Binding RelativeSource={RelativeSource PreviousData}}" Value="{x:Null}">
                                                        <Setter TargetName="border" Property="Rectangle.Width" Value="1"/>
                                                    </DataTrigger>
                                                </ControlTemplate.Triggers>
                                            </ControlTemplate>
                                        </Setter.Value>
                                    </Setter>
                                    <Style.Triggers>
                                        <DataTrigger Binding="{Binding ShowTitleBar, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Controls:MetroWindow}}}" Value="True">
                                            <Setter Property="Foreground" Value="White" />
                                        </DataTrigger>
                                    </Style.Triggers>
                                </Style>
                            </ItemsControl.ItemContainerStyle>
                        </ItemsControl>
                        <Button x:Name="PART_Min"
                            Margin="2,0,0,0"
                            Width="20"
                            Height="20"
                            Style="{DynamicResource ChromelessButtonStyle}"
                            Padding="0"
                            ToolTip="{DynamicResource WindowCommandsMinimiseToolTip}"
                            Visibility="{Binding ShowMinButton, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Controls:MetroWindow}}, Converter={StaticResource BooleanToVisibilityConverter}}"
                            FontFamily="Marlett"
                            Foreground="{TemplateBinding Foreground}"
                            Opacity="0.8" Content="0" />

                        <Button x:Name="PART_Max"
                            Margin="2,0,0,0"
                            Width="20"
                            Height="20"
                            Style="{DynamicResource ChromelessButtonStyle}"
                            Padding="0"
                            Foreground="{TemplateBinding Foreground}"
                            Visibility="{Binding ShowMaxRestoreButton, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Controls:MetroWindow}}, Converter={StaticResource BooleanToVisibilityConverter}}"
                            ToolTip="{DynamicResource WindowCommandsMaximiseToolTip}"
                            Opacity="0.8" FontFamily="Marlett"
                            Content="1" />

                        <Button x:Name="PART_Close"
                            Margin="2,0,0,0"
                            Width="20"
                            Height="20"
                            Style="{DynamicResource ChromelessButtonStyle}"
                            ToolTip="{DynamicResource WindowCommandsCloseToolTip}"
                            Foreground="{TemplateBinding Foreground}"
                            Opacity="0.8" FontFamily="Marlett"
                            Content="r" />
                    </StackPanel>
                   
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <DataTrigger Binding="{Binding ShowTitleBar, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Controls:MetroWindow}}}" Value="True">
                <Setter Property="Foreground" Value="White" />
            </DataTrigger>
        </Style.Triggers>
    </Style>
</ResourceDictionary>
